package controle;

import java.io.IOException;
import java.util.Vector;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.beanutils.BeanUtils;

import modelo.Atividade;
import modelo.Normal;



import dataBase.AtividadeBD;
import dataBase.NormalBD;


public class NormalList extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
	super.init(config);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	executeServlet(request, response);
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	executeServlet(request, response);
    }

    public void executeServlet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

	response.setContentType("text/html");
	HttpSession session = request.getSession(true);


	    Normal normal = new Normal();
	    NormalBD normalBD = new NormalBD();

	    Vector normais = null;

	    int event = 0;

	    try {
		event = Integer.parseInt(request.getParameter("event"));
	    } catch (Exception e) {
		event = 1;
	    }

	    switch (event) {
	    case 2:
	    	try {
	    		
	    			BeanUtils.populate(normal, request.getParameterMap());
					//filmes = processBD.findBy(atividade);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	    	break;
	    	
	    case 5:
			String message = "";
			
			break;	
	    	
	    default:
	    	try {
					normais = normalBD.findAll();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			break;
	    }
	    try {
			normais = normalBD.findAll();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	    request.setAttribute("normais", normais);

	    getServletContext().getRequestDispatcher("/normalList.jsp").forward(request, response);
	    
	

    }

}
